package cn.xaut.剑指offer.m01;

/**
 * 剑指 Offer 05. 替换空格
 */
public class demo07 {

    public String replaceSpace(String s) {

        StringBuffer sb = new StringBuffer();
        for (char c : s.toCharArray()) {
            if (c == ' ')
                sb.append("%20");
            else 
                sb.append(c);
        }
        return sb.toString();
    }

    public static void main(String[] args) {

        String s = "We are happy.";
        System.out.println(new demo07().replaceSpace(s));
    }
}